class Solution(object):
    def decrypt(self, code, k):
        n = len(code)
        out = [0] * n
        if k == 0:
            return out
        if k < 0:
            k = -k
            s = n - k
            out[0] = sum(code[s:])
            for i in range(1, n):
                out[i] += out[i - 1] + code[i - 1] - code[s % n]
                s += 1
        else:
            s = k + 1
            out[0] = sum(code[1: s])
            for i in range(1, n):
                out[i] += out[i - 1] - code[i] + code[s % n]
                s += 1
        return out